﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace Pixysoft.PaymentGateway
{
    /// <summary>
    /// utilMD5Util 的摘要说明。
    /// </summary>
    class MD5Util
    {
        /// <summary>
        /// 获取大写的MD5签名结果
        /// </summary>
        /// <param name="encypStr"></param>
        /// <returns></returns>
        public static string GetMD5(string encypStr)
        {
            string retStr;
            MD5CryptoServiceProvider m5 = new MD5CryptoServiceProvider();

            //创建md5对象
            byte[] inputBye;
            byte[] outputBye;

            //使用GB2312编码方式把字符串转化为字节数组．
            inputBye = Encoding.GetEncoding("GB2312").GetBytes(encypStr);

            outputBye = m5.ComputeHash(inputBye);

            retStr = System.BitConverter.ToString(outputBye);
            retStr = retStr.Replace("-", "").ToUpper();
            return retStr;
        }

        public MD5Util()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        private void test()
        {
            string pwd = "";

            Console.Write(GetMD5(pwd));
        }
    }
}
